package view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenu;
import javax.swing.JMenuItem;

import model.ChartGenerator;

/**
 * ovviamento potevo fare i listener a parte, ma per due scelte non ne valeva la
 * pena;
 * 
 * @author koelio
 * 
 */
public class MenuPane extends JMenu {

	private static final long serialVersionUID = 0;
	ChartGenerator chart;

	public MenuPane(ChartGenerator chart) {
		super("Filter");
		this.chart = chart;

		JMenuItem teamMenu = new JMenuItem("Teams");
		teamMenu.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				control1();
			}
		});
		add(teamMenu);

		JMenuItem facultMenu = new JMenuItem("Faculties");
		facultMenu.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				control2();
			}
		});
		add(facultMenu);

	}

	/**
	 * Necessario per l'update selettivo sull'observer cioè quale classifica
	 * voglio vedere se Teams o Faculties, uso (1) o (2)
	 * 
	 * @see RatingPane
	 * @see ChartGenerator
	 */
	public void control1() {
		chart.setTeamStatus(true);

	}

	public void control2() {
		chart.setFacStatus(true);
	}

}
